#!/usr/bin/env node

//buffer 弃用
var buf  =new Buffer.alloc(256);
buf[0] = 23;

console.log('buffer length',buf.length);
console.log('\n buffer content',buf);

for (let i = 0; i < 256; i++)  buf[i]=i;
console.log('\n buffer content',buf);

var end =  buf.slice(250,256);
console.log('\n buf\' s end 6 litems:',end );

end.fill(0);
console.log('\n buf\' s end 6 litems:',end );


var array= ['a',0xba,0xdf,0x00,255,10];
var buf1= new Buffer.from(array);
console.log('\n buf1:',buf1.length,buf1);

var buf2 = new Buffer.from('hello world','utf8');
console.log('\n buf2:',buf2.length,buf2.toString());

var buf3 = new Buffer.alloc(buf2.length);
buf2.copy(buf3,0,0,buf2.length);
console.log('\n buf3:',buf3.length,buf3.toString());